import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { ArenaCrossbattleRecordData } from "../arenaCrossData/ArenaCrossbattleRecordData";
import { Cache } from "../../../cache/Cache";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { EBattleResult } from "../../../../../Message/Public/EBattleResult";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
//class ArenaCrossMyMatchCellRenderer
    
    export  class ArenaCrossMyMatchCellRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.initStyle();
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */createChildren(): void
        {
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 11661311);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._tfIndex = ObjCreate.createTextField("", 0, 25, 50, 20, this, loc1);
            this._tfName = ObjCreate.createTextField("", 50, 25, 110, 20, this, loc1);
            this._bmpVS = ObjCreate.createBitmap(ImagesConst.ArenaVS, 174, 10, this);
            this._tfEnemyName = ObjCreate.createTextField("", 220, 25, 185, 20, this, loc1);
            this._bmpResult = new Object /* flash.display.Bitmap */();
            ObjCreate.setObjAttri(this._bmpResult, 415, 5, -1, -1, this);
            ObjCreate.createBg(0, 65, 475, 2, this, "SplitLine");
            LoaderHelp.addResCallBack(ResFileConst.arena, this.onResCallBack);
            return;
        }

        /* internal  */onResCallBack(): void
        {
            this._isResCompl = true;
            this.setBitmap();
            return;
        }

        /* internal  */addListeners(): void
        {
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "arenacrossbattlerecorddata") 
            {
                this._battle = arg1 as ArenaCrossbattleRecordData;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            this._tfIndex.htmlText = this._battle.index.toString();
            this._tfName.htmlText = Cache.instance.role.entityInfo.name;
            this._tfEnemyName.htmlText = "[" + EntityUtil.getProxyName(this._battle.arenaCrossBattleRecord.entityId) + "]" + this._battle.arenaCrossBattleRecord.name;
            this.setBitmap();
            return;
        }

        /* internal  */setBitmap(): void
        {
            if (this._isResCompl && this._battle) 
            {
                if (this._battle.arenaCrossBattleRecord.result.value() == EBattleResult._EBattleResultWin) 
                {
                    this._bmpResult.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaWin);
                }
                if (this._battle.arenaCrossBattleRecord.result.value() == EBattleResult._EBattleResultLose) 
                {
                    this._bmpResult.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaLose);
                }
            }
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal */ /* var */_line: ScaleBitmap;

        /* internal */ /* var */_tfIndex: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfName: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpVS: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfEnemyName: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpResult: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isResCompl: Boolean=false;

        /* internal */ /* var */_battle: ArenaCrossbattleRecordData;
    }
